<template>
    <div class="flex item">
        <div class="left">
            <span>{{ rankNum + 1 }}</span>
        </div>
        <div class="right">
            <div class="title line-clamp-2">{{ item.title }}</div>
            <p class="content line-clamp-2">{{ item.desc }}</p>
            <div class="info">
                <span class="author">
                    {{ item.nickname }}
                </span>
                <span class="views">
                    <img src="@/assets/images/hot-icon.png" alt="">
                    <!-- 四舍五入item.views -->
                    {{ item.views > 1000 ? Math.round(item.views / 1000) + 'k+' : item.views }} 热度
                </span>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    props: {
        rankNum: Number,
        item: Object
    }
}
</script>
<style lang="less" scoped>
.line-clamp-2 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.item:nth-child(1) {
    .left {
        background-image: url('@/assets/images/ranking-1.png');
        color: white;
    }
}

.item:nth-child(2) {
    .left {
        background-image: url('@/assets/images/ranking-2.png');
        color: white;
    }
}

.item:nth-child(3) {
    .left {
        background-image: url('@/assets/images/ranking-3.png');
        color: white;
    }
}

.item {
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: 0px 1px 4px #ddd;
    margin: 8px 0;

    .left {
        width: 15px;
        background-image: url('@/assets/images/ranking-other.png');
        background-size: 15px 15px;
        background-repeat: no-repeat;
        background-position-y: 2px;
        text-align: center;
        font-size: 12px;
        color: #000;
        margin-right: 10px;

        span {
            position: relative;
            left: 0px;
            top: 1px;
        }
    }

    .right {
        flex: 1;
        width: 90%;

        .title {
            font-size: 16px;
            color: #000;
            font-weight: bold;
        }

        .content {
            font-size: 14px;
            color: #999;
        }

        .info {
            display: flex;
            justify-content: space-between;
            font-size: 12px;
            margin-top: 5px;

            .author {
                color: #ddd;
            }

            .views {
                color: #ff9900;

                img {
                    width: 14px;
                    height: 14px;
                }
            }
        }
    }
}
</style>